package sample;

import org.apache.wicket.Application;
import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.HttpSessionStore;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.session.ISessionStore;
import org.apache.wicket.settings.IExceptionSettings;

import sample.page.CreatePage;
import sample.page.DeletePage;
import sample.page.ErrorPage;
import sample.page.ReadPage;
import sample.page.MainPage;
import sample.page.TopPage;
import sample.page.UpdatePage;
import sample.util.ErrorRequestCycle;

public class GoogleAppEngine_SampleApplication extends WebApplication {
	public GoogleAppEngine_SampleApplication() {
	}

	protected void init() {
		super.init();
		getRequestCycleSettings().setResponseRequestEncoding("UTF-8");
		getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
		getPageSettings().setAutomaticMultiWindowSupport(false);
		getApplicationSettings().setInternalErrorPage(ErrorPage.class);
		getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
		mountBookmarkablePage("/Top", TopPage.class);
		mountBookmarkablePage("/Main", MainPage.class);
		mountBookmarkablePage("/Create",CreatePage.class);
		mountBookmarkablePage("Read",ReadPage.class);
		mountBookmarkablePage("/Update",UpdatePage.class);
		mountBookmarkablePage("/Delete",DeletePage.class);
	}
	
	public RequestCycle newRequestCycle(Request request, Response response) {
		return new ErrorRequestCycle(this, (WebRequest)request, (WebResponse)response);
	}

	public String getConfigurationType() {
		return Application.DEPLOYMENT;
	}

	protected ISessionStore newSessionStore() {
		return new HttpSessionStore(this);
	}
	
	public Class<TopPage> getHomePage() {
		return TopPage.class;
	}
}
